<template>
  <div class="bad">
    <DFPageList ref="dfPageListRef" :page-options="pageOptions" />
  </div>
</template>

<script lang="ts" setup name="Bad">
import { ref } from 'vue'
import lang from './lang'
import { addBad, delBad, pageBad, updateBad } from '@/api/base/bad'
import { useMixins } from '@/hooks/useMixins'

const { loadLangFn ,getDictDataListFn} = useMixins()

const dfPageListRef: any = ref(null)

loadLangFn(lang)

const badLevelList = ref([])

const pageOptions = {
  searchForm: {
    formSchemas: [
      {
        label: 'badName',
      },
      {
        label: 'badCode',
      },
    ],
  },
  table: {
    columns: [
      {
        width: 120,
        label: 'badName',
      },
      {
        width: 120,
        label: 'badCode',
      },
      {
        width: 120,
        label: 'remark',
        common: true,
      },
    ],
    action: {
      columns: [
        {
          label: 'edit',
        },
        {
          label: 'delete',
        },
      ],
    },
    operaColumn: [
      {
        label: 'add',
      },
    ],
    requestFn: pageBad,
    delRequestFn: delBad,
  },
  modalFormDialog: {
    formSchemas: [
      {
        label: 'badName',
        required: true,
      },
      {
        label: 'badCode',
        required: true,
        editDialogDisabled:true
      },
      {
        label: 'badLevelName',
        prop: 'badLevelCode',
        required: true,
        component: 'NSelect',
        options: badLevelList,
      },
      {
        label: 'remark',
        common: true,
        type: 'textarea',
      },
    ],
    addDataFn: addBad,
    updateDataFn: updateBad,
  },
}



async function initDictData() {
    const res = await Promise.all([
      getDictDataListFn('bad_level'),
    ]);

    const [list1] = res;

    badLevelList.value = list1;
  }

  initDictData();
</script>
